﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DevExpress.XtraEditors;


namespace QuanLyPhongKham
{
    public class BaseUserControl: XtraUserControl, ICanValidate
    {
        public event EventHandler<CloseEventArgs> FormClosing;

        /// <summary>
        /// Gets or sets the form main.
        /// </summary>
        /// <value>The form main.</value>
        public MainForm FormMain { get; set; }
        /// <summary>
        /// Gets or sets the control caption.
        /// </summary>
        /// <value>The control caption.</value>
        public BaseCaptionControl ControlCaption { get; set; }
        /// <summary>
        /// Gets or sets the title.
        /// </summary>
        /// <value>The title.</value>
        public string Title { get; set; }
        /// <summary>
        /// Gets or sets the show export buttons.
        /// </summary>
        /// <value>The show export buttons.</value>
        public bool ShowExportButtons {
            get { 
                if (this.ControlCaption != null) {
                    return this.ControlCaption.AllowExport;
                }
                throw new Exception("ControlCaption is null");
            }
            set {
                if (this.ControlCaption != null)
                    this.ControlCaption.AllowExport = value;
            }
        }

        /// <summary>
        /// Gets or sets the show search.
        /// </summary>
        /// <value>The show search.</value>
        public bool ShowSearch {
            get { 
                if (this.ControlCaption != null) {
                    return this.ControlCaption.AllowSearch;
                }
                throw new Exception("ControlCaption is null");
            }
            set {
                if (this.ControlCaption != null)
                    this.ControlCaption.AllowSearch = value;
            }
        }

        public BaseUserControl()
        {
            this.Title = string.Empty;
        }
        
        /// <summary>
        /// Validates this instance.
        /// </summary>
        /// <returns></returns>
        public virtual string Validate()
        {
            // TODO: Implement this method
            return string.Empty;
        }

        /// <summary>
        /// Captions the button click.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="QuanLyPhongKham.CaptionEventArgs" /> instance containing the event data.</param>
        public virtual void CaptionButtonClick(object sender, CaptionEventArgs e)
        { 
        }

        
    }
}
